﻿<script src="~/lib/vue/dist/vue.global.js"></script>
<link href="~/lib/element-plus/dist/index.css" rel="stylesheet" />
<script src="~/lib/element-plus/dist/index.full.js"></script>
<script src="~/lib/axios/dist/axios.js"></script>
<div id="app">
	<table width="100%">
        <tr>
            <td>
                <p color="black">您正在做的业务是:人力资源--调动管理--调动审核</p>
            </td>
        </tr>
		<tr>
			<td align="right">
				<input type="button" value="审 核" v-on:click="TiJiao()" class="BUTTON_STYLE1">
                <input type="button" value="返 回" class="BUTTON_STYLE1" v-on:click="goBack()">
			</td>
		</tr>
	</table>
	<table width="100%" border="1" cellpadding=0 cellspacing=1
		   bordercolorlight=#848284 bordercolordark=#eeeeee
		   class="TABLE_STYLE1">
		<tr>
			<td class="TD_STYLE1">
				档案编号
			</td>
			<td class="TD_STYLE2">
				<el-input v-model="obj.humanId" class="aaa"></el-input>
			</td>
			<td class="TD_STYLE1">
				姓名
			</td>
			<td class="TD_STYLE2">
				<el-input v-model="obj.humanName" class="aaa"></el-input>
			</td>
			<td>&nbsp; </td>
			<td>&nbsp; </td>
			<td>&nbsp; </td>
			<td>&nbsp; </td>
		</tr>
		<tr>
			<td class="TD_STYLE1">
				原一级机构
			</td>
			<td class="TD_STYLE2">
				<el-input v-model="obj.firstKindName" class="aaa"></el-input>
			</td>
			<td class="TD_STYLE1">
				原二级机构
			</td>
			<td class="TD_STYLE2">
				<el-input v-model="obj.secondKindName" class="aaa"></el-input>
			</td>
			<td class="TD_STYLE1">
				原三级机构
			</td>
			<td class="TD_STYLE2">
				<el-input v-model="obj.thirdKindName" class="aaa"></el-input>
			</td>
			<td>&nbsp; </td>
			<td>&nbsp; </td>
		</tr>
		<tr>
			<td class="TD_STYLE1">
				原职位分类
			</td>
			<td class="TD_STYLE2">
				<el-input v-model="obj.majorKindName" class="aaa"></el-input>
			</td>
			<td class="TD_STYLE1">
				原职位名称
			</td>
			<td class="TD_STYLE2">
				<el-input v-model="obj.majorName" class="aaa"></el-input>
			</td>
			<td class="TD_STYLE1">
				原薪酬标准
			</td>
			<td class="TD_STYLE2">
				<el-input v-model="obj.salaryStandardName" class="aaa"></el-input>
			</td>
			<td class="TD_STYLE1">
				原薪酬总额
			</td>
			<td class="TD_STYLE2">
				<el-input v-model="obj.salarySum" class="aaa"></el-input>
			</td>
		</tr>
		<tr>
			<td class="TD_STYLE1">
				新一级机构
			</td>
			<td class="TD_STYLE2">
				<el-select v-model="obj.newfirst"
						   placeholder="请选择"
						   size="large"
						   class="aaa">
					<el-option v-for="item in firstoptions"
							   :key="item.ffkId"
							   :label="item.firstKindName"
							   :value="item.firstKindId+item.firstKindName"
							   v-on:click="firstClick(item.firstKindId)" />
				</el-select>
			</td>
			<td class="TD_STYLE1">
				新二级机构
			</td>
			<td class="TD_STYLE2">
				<el-select v-model="obj.newsecond"
						   placeholder="请选择"
						   size="large"
						   class="aaa">
					<el-option v-for="item in secondoptions"
							   :key="item.fskId"
							   :label="item.secondKindName"
							   :value="item.secondKindId+item.secondKindName"
							   v-on:click="secondClick(item.secondKindId)" />
				</el-select>
			</td>
			<td class="TD_STYLE1">
				新三级机构
			</td>
			<td class="TD_STYLE2">
				<el-select v-model="obj.newthird"
						   placeholder="请选择"
						   size="large"
						   class="aaa">
					<el-option v-for="item in thirdoptions"
							   :key="item.ftkId"
							   :label="item.thirdKindName"
							   :value="item.thirdKindId+item.thirdKindName" />
				</el-select>
			</td>
			<td>&nbsp; </td>
			<td>&nbsp; </td>
		</tr>
		<tr>
			<td class="TD_STYLE1">
				新职位分类
			</td>
			<td class="TD_STYLE2">
				<el-select v-model="obj.newmajorKindName"
						   placeholder="请选择"
						   size="large"
						   class="aaa">
					<el-option v-for="item in majorKindNameoptions"
							   :key="item.ftkId"
							   :label="item.majorKindName"
							   :value="item.majorKindId+item.majorKindName"
							   v-on:click="majorKindNameClick(item.majorKindId)" />
				</el-select>
			</td>
			<td class="TD_STYLE1">
				新职位名称
			</td>
			<td class="TD_STYLE2">
				<el-select v-model="obj.newmajorName"
						   placeholder="请选择"
						   size="large"
						   class="aaa">
					<el-option v-for="item in newmajorNameoptions"
							   :key="item.ftkId"
							   :label="item.majorName"
							   :value="item.majorId+item.majorName" />
				</el-select>
			</td>
			<td class="TD_STYLE1">
				新薪酬标准
			</td>
			<td class="TD_STYLE2">
				<el-select v-model="obj.newstandardName"
						   placeholder="请选择"
						   size="large"
						   class="aaa">
					<el-option v-for="item in standardNameoptions"
							   :key="item.ftkId"
							   :label="item.standardName"
							   :value="item.standardId+item.standardName" />
				</el-select>
			</td>
			<td class="TD_STYLE1">
				新薪酬总额
			</td>
			<td class="TD_STYLE2">
				<el-input v-model="obj.newsalarySum" class="aaa"></el-input>
			</td>
		</tr>
		<tr>
			<td class="TD_STYLE1">
				登记人
			</td>
			<td class="TD_STYLE2">
				<el-input v-model="obj.register" class="aaa"></el-input>
			</td>
			<td class="TD_STYLE1">
				登记时间
			</td>
			<td class="TD_STYLE2">
				<el-input v-model="obj.registTime" class="aaa"></el-input>
			</td>
			<td class="TD_STYLE1">
				复核人
			</td>
			<td class="TD_STYLE2">
				<el-input v-model="objf.checker" class="aaa"></el-input>
			</td>
			<td class="TD_STYLE1">
				复核时间
			</td>
			<td class="TD_STYLE2">
				<el-input v-model="objf.checkTime" class="aaa"></el-input>
			</td>
		</tr>
		<tr>
			<td class="TD_STYLE1">
				调动原因
			</td>
			<td class="TD_STYLE2" colspan="8">
				<textarea v-model="obj.changeReason" name="emajorRelease.majorDescribe" rows="4" cols="80" class="TEXTAREA_STYLE1"></textarea>
			</td>
		</tr>
		<tr>
			<td class="TD_STYLE1">
				复合通过意见
			</td>
			<td class="TD_STYLE2">
				<el-select v-model="objf.checkStatus"
						   placeholder="请选择"
						   size="large"
						   class="aaa">
			<el-option v-for="item in options"
							   :key="item.text"
							   :label="item.text"
							   :value="item.value" />
				</el-select>
			</td> 
		</tr>
	</table>
</div>
<script>
	const { createApp, ref, reactive, computed, watchEffect } = Vue;
	var app = createApp({
		setup() {
			const urlParams = new URLSearchParams(window.location.search);
			const rowData = JSON.parse(urlParams.get('rowData'));
			//初始化得值
			const obj = reactive({
				mchId: rowData.mchId,
				humanId: rowData.humanId,
				humanName: rowData.humanName,

				firstKindId: rowData.firstKindId,
				firstKindName: rowData.firstKindName,
				secondKindId: rowData.secondKindId,
				secondKindName: rowData.secondKindName,
				thirdKindId: rowData.thirdKindId,
				thirdKindName: rowData.thirdKindName,
				majorKindId: rowData.majorKindId,
				majorKindName: rowData.majorKindName,
				majorId: rowData.majorId,
				majorName: rowData.majorName,
				salaryStandardId: rowData.salaryStandardId,
				salaryStandardName: rowData.salaryStandardName,
				salarySum: rowData.salarySum,

				newfirstId: rowData.newFirstKindId,
				newfirst: rowData.newFirstKindName,
				newsecondId: rowData.newSecondKindId,
				newsecond: rowData.newSecondKindName,
				newthirdId: rowData.newThirdKindId,
				newthird: rowData.newThirdkindName,
				newmajorKindNameId: rowData.newMajorKindId,
				newmajorKindName: rowData.newMajorKindName,
				newmajorNameId: rowData.newMajorId,
				newmajorName: rowData.newMajorName,
				newstandardNameId: rowData.newSalaryStandardId,
				newstandardName: rowData.newSalaryStandardName,
				newsalarySum: rowData.newSalarySum,


				register: rowData.register,
				registTime: rowData.registTime,
				changeReason: rowData.changeReason,

				

			})
			const objf = reactive({
				mchId: '',
				checker:'',
				checkTime: '',
				checkStatus: '',
			})
			const options = [
				{ text: "通过", value: "true" },
				{ text: "不通过", value: "false" },
			];
			const fetchData = () => {
				// 获取存储的res.data值
				const responseDataString = sessionStorage.getItem('User');
				if (responseDataString) {
					// 将存储的字符串转换回数组
					const responseDataArray = JSON.parse(responseDataString);

					// 现在您可以访问responseDataArray数组中的元素
					objf.checker = responseDataArray.uName;
				} else {
					console.log("未找到存储的值");
				}
			};
			fetchData();
			//获取当前时间
			objf.checkTime = ref(new Date().toLocaleString());

			// 如果你想要实时更新时间，可以使用watchEffect或setInterval
			watchEffect(() => {
				const interval = setInterval(() => {
					objf.checkTime = new Date().toLocaleString();
				}, 1000);
			});

            //返回
            function goBack() {
                history.back();
            }

			//下拉框
			const firstoptions = ref();
			const secondoptions = ref();
			const thirdoptions = ref();
			const majorKindNameoptions = ref();
			const newmajorNameoptions = ref();
			const standardNameoptions = ref();
			axios.get('/CFFK/GetCFFK')
				.then(res => {
					firstoptions.value = res.data
				})
			function firstClick(fid) {
				console.info(fid)
				axios.get(`/GetCFSKById/${fid}`).then(response => {
					secondoptions.value = response.data
				}).catch(error => {
					console.error('Error fetching data:', error);
				});
			}
			function secondClick(tid) {
				console.info(tid)
				axios.get(`/GetCFTKById/${tid}`).then(response => {
					thirdoptions.value = response.data
				}).catch(error => {
					console.error('Error fetching data:', error);
				});
			}
			axios.get('/GetCMK')
				.then(res => {
					majorKindNameoptions.value = res.data
				})
			function majorKindNameClick(mknid) {
				console.info(mknid)
				axios.get(`/GetCMById/${mknid}`).then(response => {
					newmajorNameoptions.value = response.data
				}).catch(error => {
					console.error('Error fetching data:', error);
				});
			}
			axios.get('/GetSS')
				.then(res => {
					standardNameoptions.value = res.data
				})

			function TiJiao() {
				console.info(obj)
				console.info(rowData)
				if (objf.checkStatus=="true") {
					axios.defaults.headers["Content-Type"] = "application/x-www-form-urlencoded";

					axios.post('/HF/UpdateHFMC', {
						HumanId: rowData.humanId,
						FirstKindId: rowData.newFirstKindId,
						FirstKindName: rowData.newFirstKindName,
						SecondKindId: rowData.newSecondKindId,
						SecondKindName: rowData.newSecondKindName,
						ThirdKindId: rowData.newThirdKindId,
						ThirdkindName: rowData.newThirdkindName,
						HumanMajorKindId: rowData.newMajorKindId,
						HumanMajorKindName: rowData.newMajorKindName,

						HumanMajorId: rowData.newMajorId,
						HunmaMajorName: rowData.newMajorName,
						SalaryStandardId: rowData.newSalaryStandardId,
						SalaryStandardName: rowData.newSalaryStandardName,

						SalarySum: rowData.newSalarySum
					}).then(res => {
						console.info(res.data)
					}).catch(error => {
						console.error("请求失败:", error.response ? error.response.data : error.message);
					});


					axios.post('/ReviewMC/UpdateReviewMC', {
						mchId: rowData.mchId,
						checker: objf.checker,
						checkTime: objf.checkTime,
						checkStatus: objf.checkStatus,
					}).then(res => {
						console.info(res.data)
						if (res.data) {
							alert("复核通过")
							window.location.href = `/ReviewMC/Index`;
						}
					})
				} else {
					alert("复核不通过")
				}
				
			}
		
				return {
				obj,
				objf,
				firstoptions,
				secondoptions,
				thirdoptions,
				majorKindNameoptions,
				newmajorNameoptions,
				standardNameoptions,
				firstClick,
				secondClick,
				majorKindNameClick,
				TiJiao,
				options,
                goBack
			}
		}
	})
	app.use(ElementPlus);
	app.mount("#app");
</script>
<style type="text/css">
	body {
		background-color: #FFFFBB;
		border: 1px solid #FFDB6F;
		display: block;
		margin: 8px;
	}

</style>
